import { lcRequest } from "@/api/reqeust";
import type { Essay } from "@/model/essay";
import type { Movie } from "@/model/movie";
import type { BgImage, BingImage } from "@/model/bgImg";
import type { TopList } from "@/model/topList";
import type { AncientPoetry } from "@/model/ancientPoetry";
import type { Song } from "@/model/song";
import type { Briefing } from "@/model/briefing";

export function api_get_movie_info() {
    return lcRequest.get<any, Movie>({
        url: "/movie"
    });
}

// 每日一文

export function api_get_essay() {
    return lcRequest.get<any, Essay>({
        // baseURL: 'https://meiriyiwen.com/'
        // baseURL: '/api'

        url: "/essay"
    });
}

// bing 每日壁纸
export function api_get_bingimg() {
    return lcRequest.request<any, BingImage>({
        url: "/bingbgimg",
        params: {
            height: document.documentElement.clientHeight,
            width: document.documentElement.clientWidth
        }
    });
}
// unsplash 壁纸
export function api_get_bgImg() {
    return lcRequest.get<any, BgImage>({
        url: "/bgimg"
    });
}

const topListId = {
    WeiBo: "KqndgxeLl9",
    ZhiHuRiBao: "KMZd7VOvrO",
    TouTiao: "toutiao",
    TodayInHistory: "KMZd7X3erO",
    BiliBili: "74KvxwokxM"
};
export type TopListId = "WeiBo" | "ZhiHuRiBao" | "TouTiao" | "TodayInHistory" | "BiliBili";
// 热榜
export function api_get_top_list(idFlag: TopListId = "WeiBo") {
    return lcRequest.get<any, TopList>({
        url: `/toplist?id=${topListId[idFlag]}`
    });
}

// 古诗词
export function api_get_gushici() {
    return lcRequest.get<any, AncientPoetry>({
        url: `/ancientpoetry`
    });
}

// 背景歌曲
export function api_get_song() {
    return lcRequest.get<{ name: string }, Song>({
        url: "/song",
        interceptors: {}
    });
}

// 简报
export type Category = "时事" | "国内" | "国际" | "商业";
export function api_get_briefing(ip: string = "101.68.1.1", count: number = 12, category: Category = "时事") {
    return lcRequest.get<any, Briefing>({
        url: `/briefing`,
        params: {
            ip,
            count,
            category
        }
    });
}

// ip
export function api_get_Ip() {
    return lcRequest.get<any, any, { ip: string }>({
        baseURL: "https://api.ipify.org/?format=json"
    });
}
